/**
 * 详情对话框
 */
var FactoryVideoTimeInfoDlg = {
    data: {
        factoryVideoId: "",
        showTime: "",
        title: "",
        description: "",
        image: "",
        url: "",
        status: "",
        createTime: "",
        updateTime: "",
        recordStatus: ""
    }
};

layui.use(['form', 'admin', 'ax','laydate','simTool'], function () {
    var $ = layui.jquery;
    var $ax = layui.ax;
    var form = layui.form;
    var admin = layui.admin;
    var laydate = layui.laydate;
    var simTool = layui.simTool;

    //让当前iframe弹层高度适应
    admin.iframeAuto();

    var simTool = new simTool("/upload/video","#videoBtn");
    simTool.uploadVideo();
    //获取详情信息，填充表单
    var ajax = new $ax(Feng.ctxPath + "/factoryVideoTime/detail?id=" + Feng.getUrlParam("id"));
    var result = ajax.start();
    form.val('factoryVideoTimeForm', result.data);
    /*Feng.buttonInit("status",result.data.status);
    form.render()*/
    //表单提交事件
    form.on('submit(btnSubmit)', function (data) {
        var ajax = new $ax(Feng.ctxPath + "/factoryVideoTime/editItem", function (data) {
            Feng.success("更新成功！");
            //传给上个页面，刷新table用
            admin.putTempData('formOk', true);

            //关掉对话框
            admin.closeThisDialog();
        }, function (data) {
            Feng.error("更新失败！" + data.responseJSON.message)
        });
        ajax.set(data.field);
        ajax.start();
    });

    laydate.render({
        elem: '#showTime',
        type:'time',
        range: true,
        done: function(value, date, endDate){
            console.log(value); //得到日期生成的值，如：2017-08-18
            console.log(date); //得到日期时间对象：{year: 2017, month: 8, date: 18, hours: 0, minutes: 0, seconds: 0}
            console.log(endDate); //得结束的日期时间对象，开启范围选择（range: true）才会返回。对象成员同上。
            if(date.hours>=endDate.hours){
                Feng.error("起止时间应从小到大");
                var element = document.getElementById("showTime");
                element.setvalue("")
            }
        }
    });
});